#ifndef COLOR_H_
#define COLOR_H_

#include "Object.h"
#include <sys/types.h>
#include <stdint.h>

namespace objdraw
{


/** Creates a 32-bit opaque color. */
#define RGB(r,v,b)		((r) | ((v)<<8) | ((b)<<16) | (0xff<<24))
/** Creates a 32-bit color. 32-bit colors is what all OSLib calls asking for a color want. Use RGB if you don't want to bother about alpha (semi transparency). */
#define RGBA(r,v,b,a)	((r) | ((v)<<8) | ((b)<<16) | ((a)<<24))
/** Creates a 12-bit color with 3 coefficients (red, green, blue). Alpha is set to the maximum (opaque). The r, v, b values can be from 0 to 255, they're divided to match the 12-bit pixel format. */
#define RGB12(r,v,b)	((((b)>>4)<<8) | (((v)>>4)<<4) | ((r)>>4) | (0xf<<12))
/** Creates a 12-bit color with 4 coefficients (red, green, blue, alpha). */
#define RGBA12(r,v,b,a)	((((a)>>4)<<12) | (((b)>>4)<<8) | (((v)>>4)<<4) | ((r)>>4))
/** Creates a 15-bit opaque color. */
#define RGB15(r,v,b)	((((b)>>3)<<10) | (((v)>>3)<<5) | ((r)>>3) | (1<<15))
/** Creates a 15-bit color with alpha. */
#define RGBA15(r,v,b,a)	((((a)>>7)<<15) | (((b)>>3)<<10) | (((v)>>3)<<5) | ((r)>>3))
/** Creates a 16-bit color. */
#define RGB16(r,v,b)	((((b)>>3)<<11) | (((v)>>2)<<5) | ((r)>>3))

class Color : public objdraw::Object
{
	public:
		uint8_t r,g,b,a;
		
		virtual ~Color(){}
		Color();
		Color(uint8_t r, uint8_t g, uint8_t b);
		Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
		Color(uint c);
		Color operator= (uint c);
		bool operator == (Color c);
		bool operator == (uint c);
		
		virtual void set(Color c);
		virtual void set(uint color);
		virtual void set(uint8_t r, uint8_t g, uint8_t b);
		virtual void set(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
		
		virtual void setR(uint8_t r);
		virtual void setG(uint8_t g);
		virtual void setB(uint8_t b);
		virtual void setA(uint8_t a);
		
		virtual uint8_t getR();
		virtual uint8_t getG();
		virtual uint8_t getB();
		virtual uint8_t getA();
		
		virtual uint rgba();
		virtual void use();
		virtual void useClearColor();
		
		virtual std::string toString();
};

}
#endif /*COLOR_H_*/
